package leo.gptBot.event.message;

import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import leo.gptBot.dto.request.Message;
import leo.gptBot.event.message.impl.IAllMessageEvent;
import leo.gptBot.event.message.impl.IPrivateMessageEvent;
import leo.gptBot.gpt.GPTClient;
import leo.gptBot.webSocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

/**
 * @author ：Leo
 * @date ：Created in 2024/7/22 18:55
 * @description：
 */
@Component
public class GptReplyHandler implements IPrivateMessageEvent {
    @Autowired
    GPTClient gptClient;

    @Override
    public boolean onPrivate(WebSocketSession session, Message message, String command) {

        String reply = gptClient.chat(message);
        WebSocketServer.sendPrivateMessage(session, message.getUserId(), reply, false);
        return true;
    }

    @Override
    public int weight() {
        return 0;
    }

    @Override
    public String funName() {
        return "GPTReply";
    }
}
